package eu.webhib.webblog.domain;

import eu.webhib.webblog.domain.base.CommonBaseEntityImpl;
import java.util.*;
import javax.persistence.*;
import org.apache.log4j.Logger;

//
@javax.persistence.Entity
@javax.persistence.NamedQueries({
   @javax.persistence.NamedQuery(name = "Posting_All", query = "SELECT p FROM Posting p")
})
@Access(AccessType.FIELD)
//public class Posting extends CommonParentChildEntity {
public class Posting extends CommonBaseEntityImpl {
   //
   private static final Logger log = Logger.getLogger(Posting.class);
   // attributes
   @Column(nullable = false)
   private String title;
   @Column(nullable = false)
   private String text;
   @Column(nullable = false)
   private Boolean acceptComments;
   @Temporal(javax.persistence.TemporalType.TIMESTAMP)
   private Date lastChange;
   // relations
   @ManyToOne(optional = false, fetch = FetchType.LAZY)
   User user;
   @ManyToOne(optional = false, fetch = FetchType.LAZY)
   Category category;
   @OneToMany(mappedBy = "posting")
   private List<Media> medi = new ArrayList<Media>();
   @OneToMany(mappedBy = "posting")
   private List<Comment> comments = new ArrayList<Comment>();

   //
   // getter/setter
   //

   public String getLabel() {
      return title;
   }

   public String getTitle() {
      return title;
   }

   public void setTitle(String title) {
      this.title = title;
   }

   public String getText() {
      return text;
   }

   public void setText(String text) {
      this.text = text;
   }

   public Boolean getAcceptComments() {
      return acceptComments;
   }

   public void setAcceptComments(Boolean acceptComments) {
      this.acceptComments = acceptComments;
   }

   public Date getLastChange() {
      return lastChange;
   }

   public void setLastChange(Date lastChange) {
      this.lastChange = lastChange;
   }

   public User getUser() {
      return user;
   }

   public void setUser(User user) {
      this.user = user;
   }

   public Category getCategory() {
      return category;
   }

   public void setCategory(Category category) {
      this.category = category;
   }

   public List<Media> getMedi() {
      return medi;
   }

   public List<Comment> getComments() {
      return comments;
   }
}
